<template>
  <view >
    <form>
      <xmInfo
        :projectno="dataInfo.projInfo.projectno"
        :projectname="dataInfo.projInfo.projectname"
      ></xmInfo>

      <view class="cu-form-group">
        <view class="title"
          >申请人编号</view
        >
        <view>{{ dataInfo.perid }}</view>
        
      </view>
      <view class="cu-form-group">
        <view class="title"
          >申请人</view
        >
        <view>{{ dataInfo.name }}</view>
      </view> 
      <view class="cu-form-group" style="min-height: 0"></view>
      <view class="cu-bar bg-white">
        <view class="action"
          >申请原因</view
        >
      </view>
      <view class="cu-form-group">
        {{ dataInfo.remarkes || ''}}
      </view>



      <view class="cu-form-group" style="min-height: 0"></view>
      <view class="cu-bar bg-white">
        <view class="action"
          >终止申请附件</view
        >
      </view>
      <view class="cu-form-group">
        <!-- :deletable="!!id?false:true"
              :customBtn="!id?false:true" -->
        <js-uploadfile
          v-model="dataInfo.dataMap"
          :biz-key="dataInfo.id"
          biz-type="pmTermination_file"
          :deletable="false"
          customBtn="true"
        ></js-uploadfile>
      </view>

      <view style="height: 180rpx" ></view>
      <view class="btn-group cu-bar foot cu-bar-footer" >
        <view class="flex">
          <js-bpm-button
            v-model="dataInfo.bpm"
            :biz-key="dataInfo.id"
            form-key="xm_over"
            @complete="submit"
          ></js-bpm-button>
        </view>
      </view>
    </form>

  </view>
</template>
<script>

import xmInfo from "@/pages/zfgs/index/componetns/xmInfo.vue";
import {hasPermission} from '@/common/fire.js'
export default {
  components: {
    xmInfo,
  },
  data() {
    return {
      value: 200,
      switchA: false,
      date: new Date().toISOString().substring(0, 10),
      modalName: null,
      modalNameDetail: null,
      showAddDetail: false,
      dataInfo: {},
      xmInfo: {},
      showButton: true,
      isSubmitting: false,
      formRef: null,
      customStyle: {
        width: "100%",
        textAlign: "right",
      },
      flag: hasPermission('proj:weekly:pmWeekly:edit'),
      id: "",
      x: 650, //x坐标
      y: 650, //y坐标
      localNum: '', // 声明局部变量
    };
  },
  onLoad(e) {
    if (!!e.id) {
      this.showButton = true;
      this.getweeklyPmWeeklyForm(e);
    }
  },
  methods: {
    submit() {
      if (this.isSubmitting) {
        return;
      } else {
        this.isSubmitting = true;
        try {
		  this.dataInfo.status = 4;
          this.$u.api.zfgs.pmTerminationSave(this.dataInfo).then((res) => {
            if (res.result == "true") {
              this.$u.toast(res.message);
              setTimeout(() => {
                uni.navigateBack({
                  delta: 1,
                });
              }, 500);
            } else {
              this.$u.toast(res.message);
            }
          });
        } catch (error) {
          this.$u.toast(error.message);
        } finally {
          this.isSubmitting = false;
        }
      }
    },
    getweeklyPmWeeklyForm(params) {
      this.$u.api.zfgs
        .pmTerminationForm(params)
        .then((res) => {
            this.dataInfo = res.pmTermination
        });
    },
  },
};
</script>
<style lang="scss" scoped>
$all_width: 140rpx;
$all_height: 140rpx;
.movable-area {
  z-index: 999;
  height: 97vh;
  width: 650rpx;
  // max-width: 1152rpx;
  // 固定在右边
  top: -150rpx;
  position: fixed;
  right: $all_width;
  // 固定在右下角
  pointer-events: none; //此处要加，鼠标事件可以渗透
  .movable-view {
    width: $all_width;
    height: $all_height;
    pointer-events: auto; //恢复鼠标事件
    .cu-bar {
      width: 320rpx;
    }
  }
}
.action {
  color: #303133;
}
.cu-form-group {
  flex-wrap: wrap;
}
.text-sl {
  font-size: 22px !important;
}
.cu-bar-footer {
  min-height: 80px;
}
.cu-btn {
  font-size: 16px;
  height: 40px;
}
.foot {
  z-index: 997;
  background: #fff;
}
.green {
  color: green;
}
.text-xsl {
  font-size: 60rpx !important;
}
.flex-end {
  display: flex;
  justify-content: flex-end;
}
.sub-title {
  flex-grow: 1; /* 让右侧内容占据剩余空间 */
  max-width: 200px; /* 或其他合适的最大宽度，超过这个宽度时内容会换行 */
  word-break: break-word; /* 或 overflow-wrap: break-word; 允许单词在必要时断开以适应宽度 */
}
.text-xs {
  font-size: 18rpx !important;
}
.cu-item{
  border: 1px solid #39b54a;
}
</style>